{% extends '../../../layout/admin-base.html' %}
<script src="{{ assets_path("js/base.js")}}"></script>
{% block page %}
<h3 class="page-title">
    报修器件信息 <small>新增</small>
</h3>
<ul class="breadcrumb">
    <li>
        <i class="icon-home"></i>
        <a href="index.html">基本信息管理</a> 
        <i class="icon-angle-right"></i>
    </li>
    <li>
        <a href="{{url('admin/user/staff')}}">报修器件信息管理</a>
        <i class="icon-angle-right"></i>
    </li>
    <li><span>新增</span></li>
</ul>
{% end%}
{% block content %}

<div class="row-fluid">
    <div class="span12">
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="icon-plus"></i>新增报修器件</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                </div>
            </div>
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <form id="form" action="" class="form-horizontal" method="post" enctype ="multipart/form-data">
                    <div class="control-group">
                        <label class="control-label">报修器件名<span class="required">*</span></label>
                        <div class="controls">
                            <input type="text" class="span6 m-wrap" name="Fname" />
                            <span class="help-inline">Some hint here</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">编码号<span class="required">*</span></label>
                        <div class="controls">
                            <input type="text" class="span6 m-wrap" name="Fcode" />
                            <span class="help-inline">Some hint here</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">类型<span class="required">*</span></label>
                        <div class="controls">
                            <select class="span6 m-wrap" name="Ftype_id" id="Ftype_id">
                                {% for key in device_type %}
                                        <option value="{{key}}">{{device_type[key]}}</option>
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">所属宿舍楼</label>
                        <div class="controls">
                            <select class="span6 m-wrap" name="Fdorm_id" id="Fdorm_id">
                                {% for i in drom %}
                                    <option value="{{ i['Fid'] }}">{{ i['Fdorm_name'] }}</option>
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">所属寝室</label>
                        <div class="controls">
                            <select class="span6 m-wrap" name="Froom_id" id="Froom">
                                {% for i in room %}
                                    <option value="{{ i['Fid'] }}">{{ i['Fname'] }}</option>
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">二维码</label>
                        <div class="controls">
                            <input type="text" class="span6 m-wrap" name="Fqrcode" />
                            <span class="help-inline">Some hint here</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">图片</label>
                        <div class="controls">
                            <input type="file" class="span6 m-wrap" name="Fimg" />
                            <span class="help-inline">Some hint here</span>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn blue">保存</button>
                        <button id="sub" type="button" class="btn">保存并新增下一条</button>                            
                    </div>
                </form>
                <!-- END FORM--> 
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
window.onload = function() {

    $("#Fdorm_id").change(function(){
        $.getJSON("{{ reverse_url('student.get_room', '') }}" + $(this).val(),function(data,status){
            $('#Froom').html('');
            for(var i in data){
                $('#Froom').append("<option value='" + data[i]["Fid"] + "'>" + data[i]["Fname"] + "</option>")
            }
            // $('Froom').html("<option value='" +  + "'>" + "</option>")
        });
    })
    $("#sub").click(function(){
        $('#form').attr('action', '?ltype=1')
        $('#form').submit()
        $('#form').attr('action', '')
    })

}
</script>
{% end%}